//
//  SharDetailImagesCell.m
//  NormalFramework
//
//  Created by beisheng03 on 2018/3/13.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "SharDetailImagesCell.h"
#import "ImageBrowser.h"

@interface SharDetailImagesCell ()
@property (weak, nonatomic) IBOutlet UILabel *topTitleLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomMargin;
@property (weak, nonatomic) IBOutlet ImageBrowser *myCollectionVeiw;
@property (nonatomic, strong) NSMutableArray<NSURL *> *urls;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *collectionViewW;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *collectionViewH;


@end

@implementation SharDetailImagesCell


- (NSMutableArray<NSURL *> *)urls{
    if (!_urls) {
        _urls = [NSMutableArray array];
    }
    
    
    return _urls;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.backgroundColor = [UIColor whiteColor];
    self.topTitleLabel.font = SubTitleFont;
    
    self.topTitleLabel.textColor = darkGray;
    
    self.bottomMargin.constant = 0;
    
    [self setURLStrings:@[@"http://e.hiphotos.baidu.com/zhidao/wh=450,600/sign=b88df6bb9cdda144da5c64b68787fc94/7af40ad162d9f2d3e3767647a2ec8a136327cc37.jpg",
                          @"http://e.hiphotos.baidu.com/zhidao/wh=450,600/sign=b88df6bb9cdda144da5c64b68787fc94/7af40ad162d9f2d3e3767647a2ec8a136327cc37.jpg",
                          @"http://e.hiphotos.baidu.com/zhidao/wh=450,600/sign=b88df6bb9cdda144da5c64b68787fc94/7af40ad162d9f2d3e3767647a2ec8a136327cc37.jpg"]];
    // Initialization code
}




- (void)setURLStrings:(NSArray<NSString *> *)URLStrings{
    
    
    [self.urls removeAllObjects];
    
    for (NSString *urlstr in URLStrings) {
        
        
        [self.urls addObject:[NSURL URLWithString:urlstr]];
    }
    
    
    self.myCollectionVeiw.thumPicURLs = self.urls;
    
    BrowserLayout *layout = (BrowserLayout *)self.myCollectionVeiw.collectionViewLayout;
    
    layout.itemSize = [layout itemSizeWitUrls:self.urls withMargin:KScreenW * 0.3];
    
    CGSize tempSize = [layout myCollectionViewSizeWitUrls:self.urls withMargin:KScreenW * 0.3];
    
    self.collectionViewW.constant = tempSize.width;
    
    self.collectionViewH.constant = tempSize.height;
    
    [self.myCollectionVeiw reloadData];
    
    
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
